/*
 * elbp/elbp.hh - Generic ELBP definitions.
 * Copyright (C) 2007  Mikhail Vorozhtsov
 * See the LICENSE section of the README file for details.
 */

/* $Id$ */

#ifndef HEADER_ELBP_ELBP_HH
#define HEADER_ELBP_ELBP_HH

#ifndef IN_CXX_CODE

# define ELBP_ARCH_I386 0
# define ELBP_ARCH_X86_64 1

# define ELBP_PLATFORM_PC 0
# define ELBP_PLATFORM_EFI 1

#else

START_NAMESPACE (elbp)

enum platform_t
{
  PLATFORM_PC = 0,
  PLATFORM_EFI = 1
};

union version_t
{
  struct
    {
      u32_t size : 8;
      u32_t minor : 12;
      u32_t major : 12;
    };
  u32_t raw;
};

struct mod_info_t
{
  u64_t addr;
  u64_t size;
  const char *cmdline;
  mod_info_t *next;
};

struct info_t
{
  static const u32_t MAGIC = 0x454C4250;

  version_t version;
  u8_t platform_code;
  u8_t pad[3];
  version_t platform_ver;
  version_t machine_ver;
  const char *cmdline;
  struct mod_info_t *mod_info;

  INLINE
  u64_t
  size () const
  {
    return (version.size + platform_ver.size + machine_ver.size + 3) * 8;
  }

  INLINE
  const void *
  platform_info () const
  {
    return (const void *) this + (version.size + 1) * 8;
  }

  INLINE
  const void *
  machine_info () const
  {
    return (const void *) this + (version.size + platform_ver.size + 2) * 8;
  }
} PACKED;

END_NAMESPACE

#endif /* IN_CXX_CODE */

#endif /* HEADER_ELBP_ELBP_HH */

